package vip.xiaomoli.nurse.aop;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import vip.xiaomoli.nurse.component.InjectContainer;
import vip.xiaomoli.nurse.component.InjectProcessor;
import vip.xiaomoli.nurse.component.InjectResolver;

@Aspect
@Component
public class ResultInjectAspect {

    @AfterReturning(pointcut = "@annotation(vip.xiaomoli.nurse.annotation.ResultInject)", returning = "res")
    public void afterPointcut(Object res) throws NoSuchFieldException, IllegalAccessException, InstantiationException {
        InjectResolver.resolve(res);
        InjectProcessor.process();
        InjectContainer.remove();
    }

}
